<template>
  <div style="padding: 35px 20px">
    <van-form @submit="onSubmit">
      <van-field
        v-model="username"
        name="用户名"
        placeholder="请输入手机号"
        :rules="[{ required: true, message: '请填写用户名' }]"
      />
      <div style="margin: 55px">
        <van-button
          round
          block
          type="info"
          native-type="submit"
          color="linear-gradient(to right, rgb(255, 96, 52), rgb(238, 10, 36))"
          >下一步</van-button
        >
      </div>
    </van-form>
  </div>
</template>

<script>
import service from "../../utils/service";
export default {
  data() {
    return {
      username: "",
    };
  },
  methods: {
    onSubmit(values) {
      console.log("submit", values);
      service({
        url: "api/user/docheckphone",
        method: "post",
        data: {
          tel: this.username,
        },
      }).then((res) => {
        if (res.data.code == 200) {
          // 直接跳转信息注册(手机号、密码、验证码)
          alert("可以注册");
        } else {
          // 弹出提示不可注册
          alert("手机号已被注册");
        }
      });
    },
  },
};
</script>

<style scoped>
van-form {
  background: #fff;
}
a {
  font-size: 14px;
  text-align: right;
}
</style>